home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10075 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.8 KB

  1. Path: interramp.com!usenet
  2. From: us011245@interramp.com
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: What is a test harness?
  5. Date: Mon, 04 Mar 96 20:09:01 PDT
  6. Organization: PSI Public Usenet Link
  7. Message-ID: <NEWTNews.18250.826000589.hampton@ip163.herndon7.va.interramp.com>
  8. References: <313C00F0.51B5@bhp.com.au>
  9. NNTP-Posting-Host: ip163.herndon7.va.interramp.com
  10. Mime-Version: 1.0
  11. Content-Type: TEXT/PLAIN; charset=US-ASCII
  12. X-Newsreader: NEWTNews & Chameleon -- TCP/IP for MS Windows from NetManage
  13.  
  14.  
  15. In article <313C00F0.51B5@bhp.com.au>, <bowen.richard.rw@bhp.com.au> writes:
  16. > Somewhere (I can't remember where) I read an article that 
  17. > mentioned test harnesses, but didn't elaborate.
  18. > What is a test harness and how can you use it to test a class?
  19. > Thanks,
  20. > Richard
  21.  
  22. Plan Alpha
  23. Let's pretend you want to test some class or group of classes.  One of the 
  24. things you can do is to build a new set of classes, one new class corresponding 
  25. to each of the classes you are testing, which simulate the outside world.  
  26. These classes simulate the real inputs your classes receive from the outside 
  27. world and accept the returns from your classes.  Likewise, these classes 
  28. provide any "processing" which your classes expect from the outside world and 
  29. return it to your classes.  These test classes are basically performing black 
  30. box testing on your target classes. This group of test classes is called a 
  31. parallel testing harness.  It's nice because (a) the "real classes" are tested 
  32. and (b) encapsulation is not broken, i.e., we are not "peeking" into the 
  33. innards of the classes under test.  The bad news is, as anyone knows who has 
  34. tried to do this, its really time consuming.  OK, let's turn to ....
  35.  
  36. Plan Beta
  37. Here, we build a set of subclasses corresponding to the classes under test.  
  38. Because these are subclasses, they can "see" all the non-private innards of 
  39. your classes.  They can do assertions on the integrity of your classes such as 
  40. (non-private) state/attribute reporting.  They can also exercise your classes 
  41. by driving them with specific inputs which may or may not have anything to do 
  42. with real inputs from the outside world.  In other word, they do white box 
  43. testing.  The good news here is that you can do white box testing, which many 
  44. test people feel is critical, and thet your testing class has access to a much 
  45. more complete picture of what's going on inside your classes.  The bad news is, 
  46. you have most definitely broken the encapsulation (and then some) and you are 
  47. faced with the philosophical choice of shipping the system with the inherited 
  48. subclasses or removing them and shipping a system that in some sense you 
  49. haven't really tested.  This subclassing is normally called building a derived 
  50. class test harness.
  51.  
  52. You pay your money and you take your choice..
  53.  
  54. Regards, Luther Hampton
  55.  
  56.  
  57.